This or This are code.In python there two fundamental data type
We can store these values using = in a variable
Side notes: numbers can be further categorized by their storage methods
# The '#' symbol is a comment. Python ignores it. We use it to leave notes.
# Let's store a short snippet of a target gene:
target_gene_1 = "ATGCGTAACGTTAGCGCC"
target_gene_2 = "CCGCGATTGCAATGCGTA"
gene_1_expr = 15
gene_2_expr = 20
# To see what is inside our variable, we use the print function:
print(target_gene_1)ATGCGTAACGTTAGCGCC
15
Python works exactly like a scientific calculator. The basic operators are:
Side notes: Do not skip multiplication signs as you do in math
Function is a predefined set of code to make you perform specific task.
function_name(input1, input_2, ...)
For example print() is a function to print out the string and values Here we introduce another function len() to inspect how long is the string
Variables that store text (Strings) have special actions they can perform, called methods. We can ask our DNA sequence to count specific motifs or bases using .count().
# Count the number of Adenine bases in our sequence from Step 1
a_count = target_gene_1.count("A")
print("Number of A bases:", a_count)Number of A bases: 4
# Count a specific motif (e.g., a CpG site)
cpg_count = target_gene_1.count("CG")
print("Number of CpG sites:", cpg_count)Number of CpG sites: 3
GC-content is crucial for determining the melting temperature of PCR primers (G-C base pairs form 3 hydrogen bonds, but A-T forms 2). Let’s calculate it using basic Python math
# Count the number of Adenine bases in our sequence from Step 1
a_count = target_gene_1.count("A")
print("Number of A bases:", a_count)Number of A bases: 4
# Count a specific motif (e.g., a CpG site)
cpg_count = target_gene_1.count("CG")
print("Number of CpG sites:", cpg_count)Number of CpG sites: 3
When DNA is transcribed to mRNA, Thymine (T) is replaced by Uracil (U). We can simulate this biological process instantly with the .replace() method.